<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

class CreateRechargesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('recharges', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('user_id')->comment('用户id');
            $table->decimal('money',16,2)->default(0)->comment('金额');
            $table->decimal('tmc',20,8)->default(0)->comment('E格码');
            $table->decimal('deposit')->default(0)->comment('押金');
            $table->integer('type')->default(1)->comment('充值方式1充值余额2充值会员3续费会员4项目认购');
            $table->tinyInteger('level')->default(0)->comment('续费会员等级');
            $table->integer('shop_id')->default(0)->comment('项目ID');
            $table->integer('present_card_id')->default(0)->comment('礼品卡ID');
            $table->integer('user_card_id')->default(0)->comment('会员卡ID');
            $table->integer('is_trust')->default(0)->comment('是否托管1是2否');
            $table->string('out_trade_no')->default('')->unique()->comment('商户订单流水号');
            $table->dateTime('pay_at')->nullable()->comment('付款时间');
            $table->string('payment_no')->nullable()->comment('交易单号');
            $table->integer('pay_type')->default(1)->comment('付款类型1余额2微信3E格码');
            $table->integer('status')->default(0)->comment('充值状态1待打款2已通过3未通过');
            $table->string('comment')->default('')->comment('备注');
            $table->timestamps();
        });
        DB::statement("ALTER TABLE `recharges` comment '充值表';");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('recharges');
    }
}
